package partikelTest1;

import java.awt.Color;
import java.awt.Graphics;
import java.util.*;
import  java.awt.MouseInfo;


public class Particle {

	private int xpos = 0;
	private int ypos = 0;
	private double xSpeed = 0;
	private double ySpeed = 0;
	private int xSize = 20;
	private int ySize = 20;
	
	public Particle(int xpos, int ypos){
		
		this.xpos = xpos;
		this.ypos = ypos;
		
//		xSpeed = (Math.random()*2)-1;
//		ySpeed = (Math.random()*2)-1;
		xSpeed = 2;
		ySpeed = 2;
		
	}
	
	public void update(){
		
		
		//		xSpeed += 0.005; 

	
		if(!(Math.abs(ySpeed) == 400)){
			ySpeed += 1;
			if(ySpeed >= 400)
				ySpeed = 400;

			xpos += xSpeed;
			ypos += ySpeed;

			if(xpos < 0 && xSpeed < 0 ){
				xpos += xSpeed;
				xSpeed *= -1;
			}
			if(xpos > 400){
				xpos -= xSpeed; 
				xSpeed *= -1;
			}
			if(ypos < 0 && ySpeed < 0){
				ypos += ySpeed;
				ySpeed *= -1;
			}

			if(ypos > 400){
				//			ypos -= ySpeed;
				ySpeed *= -1;

			}
		}
//		if(ySpeed < 1 && ySpeed > -1 && ypos > 380){
//			ySpeed = 0;
//		}
		
	}
	public int getXPos(){
		return xpos;
	}
	public int getYPos(){
		return ypos;
	}
	public void setXSpeed(int xSpeed){
		this.xSpeed = xSpeed;
	}
	public void setYSpeed(int ySpeed){
		this.ySpeed = ySpeed;
	}
	public void invertDirection(){
		xSpeed*=-1;
		ySpeed*=-1;
	}
	
	public void ritaUt(Graphics g){
		g.setColor(Color.black);
//		System.out.println("xpos: "+xpos+"\nYpos: "+ypos);

			
			g.fillOval(xpos, ypos, xSize,ySize);

				
	}
	
}
